package com.itheima.utils;

import com.itheima.domain.Permission;
import com.itheima.domain.UserInfo;

import java.util.List;

/**
 * 用于权限验证的工具类
 */
public class PermissionUtil {

    /**
     * 验证用户是否有对应url权限
     * @param url
     * @param user
     * @return
     */
    public static Boolean hasPermssion(String url, UserInfo user){
        List<Permission> permissions = user.getRole().getPermissions();
        for (int i = 0; i < permissions.size(); i++) {
            if (permissions.get(i).getUrl().equals(url)){
                return true;
            }
        }
        return false;
    }



}
